package server.modules.generator.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import server.modules.generator.entity.QiandaoEntity;
import server.modules.generator.service.QiandaoService;
import server.common.utils.PageUtils;
import server.common.utils.R;
import server.modules.sys.controller.AbstractController;


/**
 * 签到
 *
 * @author 
 * @email 
 */
@RestController
@RequestMapping("generator/qiandao")
public class QiandaoController  extends AbstractController {
    @Autowired
    private QiandaoService qiandaoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:qiandao:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = qiandaoService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/mylist")
    public R mylist(@RequestParam Map<String, Object> params){
        params.put("toUser",getUserId());

        PageUtils page = qiandaoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:qiandao:info")
    public R info(@PathVariable("id") Long id){
		QiandaoEntity qiandao = qiandaoService.getById(id);

        return R.ok().put("qiandao", qiandao);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:qiandao:save")
    public R save(@RequestBody QiandaoEntity qiandao){
		qiandaoService.save(qiandao);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:qiandao:update")
    public R update(@RequestBody QiandaoEntity qiandao){
		qiandaoService.updateById(qiandao);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:qiandao:delete")
    public R delete(@RequestBody Long[] ids){
		qiandaoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
